package com.strategy
{
	import com.utils.FileWriter;
	import com.utils.Utils;
	
	import flash.utils.ByteArray;
	
	import mx.controls.Alert;

	public class XMLContext
	{
		private var _myXMLStrategy:IXML;
		public function XMLContext()
		{
			
		}
		/**
		 *动态策略决定 
		 * @param strategy
		 * 
		 */		
		public function dynamicDecide(strategy:IXML):void
		{
			_myXMLStrategy = strategy;
		}
		
		/**
		 *执行具体策略 
		 * 
		 */		
		public function specificStrategy():void
		{
			if(!_myXMLStrategy){
				throw new Error("请保证先决定一个策略");
			}
			
			var saveByteArray:ByteArray = _myXMLStrategy.xmlstrategybml();
			if(saveByteArray==null){
				Alert.show("请确保选择了正确的数据类型结构");
				return;
			}
			
			FileWriter.getInstance().saveByteArray(saveByteArray);
		}
	}
}